package com.micro.play.internet.audio.book.domain.business;

import com.micro.play.internet.audio.book.domain.pojo.em.WebsiteType;
import com.micro.play.internet.audio.book.domain.pojo.vo.*;
import com.micro.play.internet.audio.book.domain.service.IPlayService;
import com.micro.play.internet.audio.book.domain.service.impl.PlayServiceAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PlayBusiness extends BaseBusiness {

    @Autowired
    private PlayServiceAdapter playServiceAdapter;

    public List<SearchBookItemVO> searchBooksByKeyword(SearchBookParamVO searchBookParam) throws Throwable {
        WebsiteType websiteType = WebsiteType.valueOf(searchBookParam.getWebsiteType());
        IPlayService iPlayService = playServiceAdapter.getService(websiteType);
        List<SearchBookItemVO> books = iPlayService.searchBooksByKeyword(searchBookParam);
        return books;
    }

    public List<AnalyzeBookCatalogItemVO> analyzeBookCataLogs(AnalyzeBookCatalogParamVO analyzeBookCatalogParam) throws Throwable {
        WebsiteType websiteType = WebsiteType.valueOf(analyzeBookCatalogParam.getWebsiteType());
        IPlayService iPlayService = playServiceAdapter.getService(websiteType);
        List<AnalyzeBookCatalogItemVO> catalogs = iPlayService.analyzeCatalogs(analyzeBookCatalogParam);
        return catalogs;
    }

    public AnalyzePlayUrlItemVO analyzePlayUrl(AnalyzePlayUrlParamVO analyzePlayUrlParam) throws Throwable {
        WebsiteType websiteType = WebsiteType.valueOf(analyzePlayUrlParam.getWebsiteType());
        IPlayService iPlayService = playServiceAdapter.getService(websiteType);
        AnalyzePlayUrlItemVO playUrlItem = iPlayService.analyzePlayUrl(analyzePlayUrlParam);
        return playUrlItem;
    }
}

